import redis
import config
redis_client = redis.Redis(host=config.REDIS_HOST, port=config.REDIS_PORT, db=config.REDIS_DB)

def redis_set(key, value):
    redis_client.set(key, value)
    return f"Key {key} set to {value}."
def redis_get(key):
    value = redis_client.get(key)
    if value:
        return value.decode('utf-8')
    return f"Key {key} not found."

def redis_delete(key):
    result = redis_client.delete(key)
    if result:
        return f"Key {key} deleted."
    return f"Key {key} not found."
def redis_set_with_expiry(key, value, seconds):
    redis_client.setex(key, int(seconds), value)
    return f"Key {key} set to {value} with expiry of {seconds} seconds."
    